/**
 */
package org.xtext.example.mydsl.myDsl.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.mydsl.myDsl.Margin;
import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.Surface;
import org.xtext.example.mydsl.myDsl.Translation;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Surface</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SurfaceImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SurfaceImpl#getTranslation <em>Translation</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SurfaceImpl#getHeight <em>Height</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SurfaceImpl#getTexture <em>Texture</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.SurfaceImpl#getMargin <em>Margin</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SurfaceImpl extends MinimalEObjectImpl.Container implements Surface
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getTranslation() <em>Translation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTranslation()
   * @generated
   * @ordered
   */
  protected Translation translation;

  /**
   * The default value of the '{@link #getHeight() <em>Height</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHeight()
   * @generated
   * @ordered
   */
  protected static final String HEIGHT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getHeight() <em>Height</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHeight()
   * @generated
   * @ordered
   */
  protected String height = HEIGHT_EDEFAULT;

  /**
   * The default value of the '{@link #getTexture() <em>Texture</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTexture()
   * @generated
   * @ordered
   */
  protected static final String TEXTURE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getTexture() <em>Texture</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTexture()
   * @generated
   * @ordered
   */
  protected String texture = TEXTURE_EDEFAULT;

  /**
   * The cached value of the '{@link #getMargin() <em>Margin</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMargin()
   * @generated
   * @ordered
   */
  protected Margin margin;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SurfaceImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MyDslPackage.Literals.SURFACE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Translation getTranslation()
  {
    return translation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTranslation(Translation newTranslation, NotificationChain msgs)
  {
    Translation oldTranslation = translation;
    translation = newTranslation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__TRANSLATION, oldTranslation, newTranslation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTranslation(Translation newTranslation)
  {
    if (newTranslation != translation)
    {
      NotificationChain msgs = null;
      if (translation != null)
        msgs = ((InternalEObject)translation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SURFACE__TRANSLATION, null, msgs);
      if (newTranslation != null)
        msgs = ((InternalEObject)newTranslation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SURFACE__TRANSLATION, null, msgs);
      msgs = basicSetTranslation(newTranslation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__TRANSLATION, newTranslation, newTranslation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getHeight()
  {
    return height;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHeight(String newHeight)
  {
    String oldHeight = height;
    height = newHeight;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__HEIGHT, oldHeight, height));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getTexture()
  {
    return texture;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTexture(String newTexture)
  {
    String oldTexture = texture;
    texture = newTexture;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__TEXTURE, oldTexture, texture));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Margin getMargin()
  {
    return margin;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMargin(Margin newMargin, NotificationChain msgs)
  {
    Margin oldMargin = margin;
    margin = newMargin;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__MARGIN, oldMargin, newMargin);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMargin(Margin newMargin)
  {
    if (newMargin != margin)
    {
      NotificationChain msgs = null;
      if (margin != null)
        msgs = ((InternalEObject)margin).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SURFACE__MARGIN, null, msgs);
      if (newMargin != null)
        msgs = ((InternalEObject)newMargin).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.SURFACE__MARGIN, null, msgs);
      msgs = basicSetMargin(newMargin, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.SURFACE__MARGIN, newMargin, newMargin));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDslPackage.SURFACE__TRANSLATION:
        return basicSetTranslation(null, msgs);
      case MyDslPackage.SURFACE__MARGIN:
        return basicSetMargin(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MyDslPackage.SURFACE__NAME:
        return getName();
      case MyDslPackage.SURFACE__TRANSLATION:
        return getTranslation();
      case MyDslPackage.SURFACE__HEIGHT:
        return getHeight();
      case MyDslPackage.SURFACE__TEXTURE:
        return getTexture();
      case MyDslPackage.SURFACE__MARGIN:
        return getMargin();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MyDslPackage.SURFACE__NAME:
        setName((String)newValue);
        return;
      case MyDslPackage.SURFACE__TRANSLATION:
        setTranslation((Translation)newValue);
        return;
      case MyDslPackage.SURFACE__HEIGHT:
        setHeight((String)newValue);
        return;
      case MyDslPackage.SURFACE__TEXTURE:
        setTexture((String)newValue);
        return;
      case MyDslPackage.SURFACE__MARGIN:
        setMargin((Margin)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.SURFACE__NAME:
        setName(NAME_EDEFAULT);
        return;
      case MyDslPackage.SURFACE__TRANSLATION:
        setTranslation((Translation)null);
        return;
      case MyDslPackage.SURFACE__HEIGHT:
        setHeight(HEIGHT_EDEFAULT);
        return;
      case MyDslPackage.SURFACE__TEXTURE:
        setTexture(TEXTURE_EDEFAULT);
        return;
      case MyDslPackage.SURFACE__MARGIN:
        setMargin((Margin)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.SURFACE__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case MyDslPackage.SURFACE__TRANSLATION:
        return translation != null;
      case MyDslPackage.SURFACE__HEIGHT:
        return HEIGHT_EDEFAULT == null ? height != null : !HEIGHT_EDEFAULT.equals(height);
      case MyDslPackage.SURFACE__TEXTURE:
        return TEXTURE_EDEFAULT == null ? texture != null : !TEXTURE_EDEFAULT.equals(texture);
      case MyDslPackage.SURFACE__MARGIN:
        return margin != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", height: ");
    result.append(height);
    result.append(", texture: ");
    result.append(texture);
    result.append(')');
    return result.toString();
  }

} //SurfaceImpl
